import { ref, onMounted, computed } from 'vue';
import { type PersonInter, type Persons } from '@/types'
export default function () {
    interface per {
        id: string,
        name: string,
        sex: string
    }
    let obj = ref<per>({
        id: "21242343",
        name: "姓名",
        sex: "男"
    })
    let objI = ref<PersonInter>({
        id: "123",
        name: "ref定义对象",
        age: 18
    })
    let objList = ref<PersonInter[]>(
        [
            { id: "12345345345", name: "张山", age: 28 },
            { id: "64356545645", name: "李四", age: 21 },
            { id: "54674567", name: "王五1", age: 45 },
        ]
    )
    //或者
    // let objList: Persons = [
    //     { id: "12345345345", name: "张山", age: 28 },
    //     { id: "64356545645", name: "李四", age: 21 },
    //     { id: "54674567", name: "王五1", age: 45 },
    // ]
    //数据
    let sum = ref(0)
    //方法
    function add() {
        sum.value += 1;
    }
    //钩子
    onMounted(() => {
        add()
    })
    //计算属性
    let bigSum = computed(() => {
        return sum.value * 10
    })
    return { sum, add, bigSum, obj, objI, objList }
}